package com.wr.modules.system.common.utils;

import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * @author ROG
 */
@Component
public class RandomPwdUtil {

    public static String getPwd() {
        return makeRandomPassword(8);
    }

    //产生8位随机数
    public static String makeRandomPassword(int len) {
        char charr[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".toCharArray();
        StringBuilder sb = new StringBuilder();
        Random r = new Random();
        for (int x = 0; x < len; ++x) {
            sb.append(charr[r.nextInt(charr.length)]);
        }
        return sb.toString();

    }

}
